<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>地区设置</title>
    <link rel="stylesheet" href="http://static-online.zhaogangtest.com/publicresource/css/bootstrap-table.css">
    <link rel="stylesheet" href="../../../resources/public/css/iconfont.min.css">
    <link rel="stylesheet" href="../../../resources/public/css/table.css">
    <link rel="stylesheet" href="../../../resources/public/css/scmstrap.css">
</head>

<body>
    <div class="leftside-sub">
        <div class="leftside-subTitle">查询</div>
        <div class="leftside-subinner">
            <div class="radio-list">
                <ul>
                    <li>
                        <label class="mycheckradio">
                            <em></em>江阴
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>杭州
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>宁波
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>台州
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>直发
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>门市
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>上海
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>江苏
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>阳东
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>无锡
                        </label>
                    </li>
                    <li>
                        <label class="mycheckradio">
                            <em></em>常州
                        </label>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div class="main main-sub">
        <!-- 条件区域 -->
        <!-- <div class="form-list">
            <div class="group">
                <label>品名名称</label>
                <div class="scm-input-wrap">
                    <input type="text" class="scm-input" placeholder="">
                </div>
            </div>
            <div class="group group-select">
                <label>状态</label>
                <div class='selectshow selectshowAction scm-input-wrap'>
                    <input type="text" class="scm-input hand" readonly="" placeholder="全部">
                </div>
                <ul class="select" style="display: none;">
                    <li>全部</li>
                    <li>活跃</li>
                    <li>睡眠</li>
                </ul>
            </div>

        </div> -->
        <!-- 按钮 -->
        <div class="operation">
            <!-- <div class="conditionbtn">
                <button class="scm-btn blue">
                    <i class="anticon icon-search1"></i>查询</button>
                <button class="scm-btn resetBtn">
                    <i class="anticon icon-delete"></i>重置</button>
            </div> -->
            <!-- 按钮组 -->
            <div class="scm-btn-group fr">
                <button class="scm-btn btn-sorting">
                    <i class="anticon icon-retweet"></i>排序
                </button>
            </div>
        </div>
        <div class="box-table box-tableTr">
            <table class="table table-condensed" id="table-name"></table>
        </div>
    </div>
    <!-- 地区排序 -->
    <div class="layer-sorting" style="display: none">
        <!-- 按钮 -->
        <div class="operation">
            <div class="scm-btn-group fr">
                <button class="scm-btn">
                    <i class="anticon icon-upcircle"></i>上移</button>
                <button class="scm-btn">
                    <i class="anticon icon-downcircle"></i>下移</button>
            </div>
        </div>
        <div class="box-table">
            <table class="table table-condensed" id="layer-table-sorting"></table>
        </div>
    </div>
    <script src="http://static-online.zhaogangtest.com/publicresource/js/require.js"></script>
    <script>
    require.config({
        paths: {
            "jquery": "../../../resources/public/js/jquery.min",
            "bootstrap": 'http://static-online.zhaogangtest.com/publicresource/js/bootstrap.min',
            "bootstrap-table": "../../../resources/public/js/bootstrap-table",
            "layer": "http://static-online.zhaogangtest.com/publicresource/control/layer/layer.min",
            "public": "../../../resources/public/js/public",
            "chinese": "../../../resources/public/js/chinese",
        },
        shim: {
            "jquery": {
                exports: ['jQuery', '$']
            },
            "bootstrap": {
                deps: ["jquery"]
            },
            "bootstrap-table": {
                deps: ["jquery", "bootstrap"]
            },



            "layer": {
                deps: ["jquery"],
                exports: "layer"
            },


            "public": {
                deps: ["jquery", "bootstrap-table"]
            },

            "chinese": {
                deps: ["jquery", "bootstrap-table"],
            },

        }
    });
    require(["public", "layer", "chinese"], function() {
        layer.config({
            path: 'http://static-online.zhaogangtest.com/publicresource/control/layer/'
        });
        $(function() {
            var page = {
                $table: $('#table-name'),
                $tableAddName: $('#table-addName'),
                init: function() {
                    this.bootstrapTable();
                    this.fn_layer();
                    this.fn_getTrData();
                    this.fn_deleteKind();


                    $(window).resize(function() {
                        page.$table.bootstrapTable('resetView', {
                            height: page.getHeight()
                        });
                    });
                },

                fn_layer: function() {
                    // 添加品类
                    $(document).on("click", ".btn-addKind", function() {
                        var index = layer.open({
                            type: 1, //page层
                            area: ['560px', ''],
                            title: '地区排序',
                            shadeClose: false,
                            btn: ['保存', '取消'],
                            shade: 0.01, //遮罩透明度
                            moveType: 1, //拖拽风格，0是默认，1是传统拖动
                            shift: -1, //0-6的动画形式，-1不开启
                            content: $('.layer-addKind'),
                            skin: "skin-searchMore",
                            yes: function(index) {
                                var text = public.fn_clearSpace($(
                                    '.layer-addKind .scm-input'
                                ).val(), 'g')
                                layer.close(index)
                                if (text) {
                                    var str =
                                        '<li><label class="mycheckradio"><em></em>' +
                                        text + '</label></li>'
                                    $(".radio-list ul").append(str)
                                }
                            }
                        })
                    });
                    // 添加品名
                    $(document).on("click", ".btn-sorting", function() {
                        var index = layer.open({
                            type: 1, //page层
                            area: ['560px', ''],
                            title: '地区排序',
                            shadeClose: false,
                            btn: ['保存', '取消'],
                            shade: 0.01, //遮罩透明度
                            moveType: 1, //拖拽风格，0是默认，1是传统拖动
                            shift: -1, //0-6的动画形式，-1不开启
                            content: $('.layer-sorting'),
                            skin: "skin-searchMore",
                            yes: function(index) {
                                layer.close(index)
                            }
                        })
                        $('#layer-table-sorting').bootstrapTable({
                            uniqueId: "id",
                            pagination: true, //在表格底部显示分页工具栏
                            pageSize: 50,
                            pageNumber: 1,
                            pageList: [10, 25, 50, 100],
                            height: 320,
                            // showFooter: true,
                            showColumns: false,
                            showRefresh: false,
                            //                    showToggle:true,
                            search: false,
                            //                    showPaginationSwitch:true,
                            // detailView: true,
                            // detailFormatter: page.showdetail,
                            // detailFormatter: this.showChild,
                            // onExpandRow: this.expandRow,
                            // onCollapseRow: this.collapseRow,
                            locales: 'zh-CN',
                            fixedColumns: false,
                            fixedNumber: 1,
                            url: '../data/erp/tablelist-district-setting-child.json',
                            sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）

                            columns: [{
                                "field": "n1",
                                "title": "地区代码",
                            }, {
                                "field": "n2",
                                "title": "地区名称",
                            }, {
                                "field": "n3",
                                "title": "备注",
                            }]
                        });

                    });
                },
                bootstrapTable: function() {
                    page.$table.bootstrapTable({
                        pagination: true, //在表格底部显示分页工具栏
                        pageSize: 50,
                        pageNumber: 1,
                        pageList: [10, 25, 50, 100],
                        height: this.getHeight(),
                        showFooter: false,
                        showColumns: false,
                        showRefresh: false,
                        //                    showToggle:true,
                        search: false,
                        //                    showPaginationSwitch:true,
                        // detailView: true,
                        // detailFormatter: this.showChild,
                        // onExpandRow: this.expandRow,
                        // onCollapseRow: this.collapseRow,
                        locales: 'zh-CN',

                        uniqueId: "id",
                        fixedColumns: true,
                        url: '../data/erp/tablelist-district-setting.json',
                        sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）

                        columns: [{
                            "field": "n1",
                            "title": "地区名称",
                        }, {
                            "field": "n2",
                            "title": "地区代码",

                        }, {
                            "field": "n3",
                            "title": "备注",
                        }]
                    });
                },
                // 表格高度
                getHeight: function() {
                    var height = public.fn_tableHeight()
                    return $(window).height() - height;
                },
                //获取选中行数据
                fn_getTrData: function() {
                    $(document).on('click', '.box-tableTr .table tbody>tr', function() {
                        var id = $(this).closest('tr').attr('data-uniqueid');
                        if ($(this).hasClass('active')) {
                            var data = page.$table.bootstrapTable(
                                'getRowByUniqueId', id); //获取选中行的数据
                            console.log(data);

                        }

                    })

                },
                // 删除品类
                fn_deleteKind: function() {
                    $(document).on('click', '.btn-deleteKind', function() {
                        $(".radio-list ul li.active").remove()
                    })
                }

            }
            page.init();
        })

    })
    </script>
</body>

</html>